#define _CRT_SECURE_NO_WARNINGS 1
#include <vector>
using namespace std;
class Solution {
public:
    int maxArea(vector<int>& height)
    {
        int max = 0;
        int left = 0, right = height.size() - 1;
        while (left <= right)
        {
            int length = right - left;
            int high = height[left] < height[right] ? height[left] : height[right];
            int capacity = length * high;
            if (capacity > max)
            {
                max = capacity;
            }
            if (height[left] > height[right])
            {
                right--;
            }
            else
            {
                left++;
            }
        }
        return max;
    }
};